package com.mingshashan.building.easy.core.exception;

/**
 * @author jasonxu
 */
public class EasyException extends Exception {

    private EasyErrorObject errorObject;

    public EasyException(EasyErrorObject errorObject) {
        this(errorObject, null);
    }

    public EasyException(EasyErrorObject errorObject, Throwable cause) {
        super(cause);
        this.errorObject = errorObject;
    }

    public EasyErrorObject getErrorObject() {
        return this.errorObject;
    }

    @Override
    public String getMessage() {
        if (this.errorObject != null) {
            return this.errorObject.getMessage();
        }
        return super.getMessage();
    }
}
